package com.fbinggun.fattribute.effect;

import com.fbinggun.fattribute.attribute.IAttribute;
import com.fbinggun.fattribute.data.EntityData;
import org.bukkit.event.entity.EntityDamageByEntityEvent;

import java.util.Map;

public abstract class IEffect {
    int duration =20;
    double modification;
    EntityData source;

    /**
     * 创建效果
     * @param duration 持续时间
     * @param modification 增幅系数
     * @param source 给与效果的实体（发起源）
     */
    public IEffect(int duration, double modification,EntityData source) {
        this.duration = duration;
        this.modification = modification;
        this.source=source;
    }

    public void setDuration(int duration) {
        this.duration = duration;
    }

    public void setModification(double modification) {
        this.modification = modification;
    }

    public EntityData getSource() {
        return source;
    }

    public void setSource(EntityData source) {
        this.source = source;
    }

    /**
     * 伤害修改器 如果实体存在这个 效果 触发伤害监听 会经过此方法
     * @param entityData 拥有此效果的实体
     * @param map 伤害集合
     * @param event 伤害监听器
     * @return
     */
    public Map<IAttribute,Double> modifyDamage(EntityData entityData, Map<IAttribute,Double> map, EntityDamageByEntityEvent event){
        return map;
    }

    public abstract void tick(EntityData entityData);

    public int getDuration() {
        return duration;
    }

    public double getModification() {
        return modification;
    }
}
